/**
 * 
 */
package com.sebscape.sebcms.setup.services;

import javax.servlet.ServletContext;

import com.sebscape.sebcms.persistence.dao.GenericDao;
import com.sebscape.sebcms.setup.domain.SetupConfiguration;

/**
 * @author Stephen
 *
 */
public class SiteConfigurationServices {
	
	public static SetupConfiguration findConfiguration( ServletContext ctx ){
		// check application scope.
		if( ctx.getAttribute( SetupConfiguration.SCOPED_VARIABLE_NAME ) != null ){
			return (SetupConfiguration)ctx.getAttribute( SetupConfiguration.SCOPED_VARIABLE_NAME );
		}
		// load it from the db.
		GenericDao<SetupConfiguration,Long> dao = new GenericDao<SetupConfiguration,Long>(SetupConfiguration.class);
		return dao.findAll().get(0);
	}
}
